from spectrogram import create_spectrogram_for_signal
from matplotlib import pyplot as plt

def plot_spectrogram_for_signal(signal, fftlen, signal_sampling_freq, freq_snapshots_per_sec):
    '''Plots the given signal's spectrogram.
    
    signal - the signal, which spectrogram is to be plotted
    fftlen - FFT length
    signal_sampling_freq - the input signal sampling frequency
    freq_snapshots_per_sec - number of columns per second in the normalized spectrogram
    '''
    spectrogram = create_spectrogram_for_signal(signal, signal_sampling_freq, fftlen, freq_snapshots_per_sec)
    figure = plt.figure()
    figure.add_subplot(1, 1, 1).imshow(spectrogram.freq_snapshots, aspect='auto', cmap='hot', interpolation='nearest')
    plt.show()

def plot_spectrogram(spectrogram):
    '''Plots the given spectrogram'''
    figure = plt.figure()
    figure.add_subplot(1, 1, 1).imshow(spectrogram.freq_snapshots, aspect='auto', cmap='hot', interpolation='nearest')
    plt.show()
    
def plot_signal(signal):
    '''Plots the given signal using matplotlib pyplot.'''
    figure = plt.figure()
    figure.add_subplot(1, 1, 1).plot(signal)
    plt.show();
    
def plot_nparray(array):
    figure = plt.figure()
    figure.add_subplot(1, 1, 1).imshow(array, aspect='auto', cmap='hot', interpolation='nearest')
    plt.show()